﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Text;
using System.IO;
using System.Collections.Generic;
public partial class admin_Admin_NewsAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {

        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        GetTags GetT = new GetTags();
        int Type = int.Parse(RadioButtonList1.SelectedValue);
        string Title1 = ntitle.Text;
        string Title2 = textTit.Text;
        string Key = TextKey.Text;
        string des = ntro.Text;
        string conn = ncontent.Value;
        string htmlurl = TextBox1.Text;

        string XiangGuan = "";
        if (checkNews.Checked)
        {
            XiangGuan = GetT.GetXiangGuanWenZhang(Key);
        }

        News Addn = new News();
        if (htmlurl == "")
        {
            Addn.ADDNews(Title1, Title2, Key, des, conn, Type);
        }
        else
        {
            Addn.ADDNewsHtmlUrl(Title1, Title2, Key, des, conn, htmlurl, Type);
        }



        //
        if (Keybool.Checked)
        {
            conn = SetConnLink.GetNoneLink(conn);
            conn = SetConnLink.FormatBody(conn);
        }

        
        int NID = Addn.GetNewsTop1NID();


        string Toplianjie = WebSet.GetSingleValue("顶部连接");
        string hongxingwangzhan = WebSet.GetSingleValue("红星网站导航");
        string ProList = WebSet.GetTopnProNoPic(14);
        
        string DibuLianjie = WebSet.GetSingleValue("底部版权");

        
        string yuming = WebSet.GetSingleValue("网站域名");
        string danqiandizhi = "";
        if (htmlurl == "")
        {
            danqiandizhi = "S" + NID.ToString() + ".html";
            Addn.UPPNewsHtmlUrl(NID);
            conn = conn + "<br/>本文地址：<a href=\"" + yuming + "/" + danqiandizhi + "\">" + yuming + "/" + danqiandizhi + "</a>";
        }
        else
        {
            danqiandizhi = htmlurl;
            conn = conn + "<br/>本文地址：<a href=\"" + yuming + "/" + htmlurl + "\">" + yuming + "/" + htmlurl + "</a>";
        }
        string NewsList = WebSet.GetTopnNews(10, 18);
        Title2 += WebSet.GetSingleValue("WebTitle").ToString();
        conn += XiangGuan;
        Hashtable canshu = new Hashtable();
        canshu.Add("$Title2", Title2);
        canshu.Add("$keywords", Key);
        canshu.Add("$description", des);
        canshu.Add("$Ntitle1", Title1);
        canshu.Add("$conn", conn);
        canshu.Add("$dangqiandizhi", danqiandizhi);
        canshu.Add("$Toplianjie", Toplianjie);
        canshu.Add("$ProList", ProList);
        canshu.Add("$DibuLianjie", DibuLianjie);
        canshu.Add("$NewsList", NewsList);
        if (SetToHtml.ToHtml("newsMoBan.html", danqiandizhi, canshu))
        {
            Response.Write("<script>alert('" + "添加数据成功！" + "');window.location.href=window.location.href;</script>");
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        GetTags GetT = new GetTags();
        TextKey.Text = GetT.GetTag(ntitle.Text, ncontent.Value);


    }


}
